package cn.ecut.diy;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

/**
 * @Author ruanxin
 */
@Aspect//标注这个类是一个切面
public class AnnotationPointCut {

    @After("execution(* cn.ecut.service.UserServiceImpl.*(..))")
    public void after(){
        System.out.println("==================方法执行后==================");
    }

    @Before("execution(* cn.ecut.service.UserServiceImpl.*(..))")
    public void before(){
        System.out.println("==================方法执行前==================");
    }

    @Around("execution(* cn.ecut.service.UserServiceImpl.*(..))")
    public void round(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕前");
        System.out.println(joinPoint.getSignature());
        Object proceed = joinPoint.proceed(); //执行方法

        System.out.println("环绕后");
    }
}
